package cn.wolfcode.rbac.web.controller;

import cn.wolfcode.rbac.domain.CustomerTraceHistory;
import cn.wolfcode.rbac.query.CustomerTraceHistoryQuery;
import cn.wolfcode.rbac.service.ICustomerTraceHistoryService;
import cn.wolfcode.rbac.service.ISystemDictionaryItemService;
import cn.wolfcode.rbac.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/customerTraceHistory")
public class CustomerTraceHistoryController {

    @Autowired
    private ICustomerTraceHistoryService customertracehistoryService;

    @Autowired
    private ISystemDictionaryItemService systemDictionaryItemService;

    @RequestMapping("/list")
    public String failList(@ModelAttribute("qo") CustomerTraceHistoryQuery qo, Model model) {
        model.addAttribute("result", this.customertracehistoryService.query(qo));
        model.addAttribute("ccts", systemDictionaryItemService.selectCcts());
        return "customerTraceHistory/list";
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public JsonResult saveOrUpdate(CustomerTraceHistory entity) {
        try {
            this.customertracehistoryService.saveOrUpdate(entity);
            return new JsonResult("操作成功", true);
        } catch (Exception e) {
            e.printStackTrace();
            return new JsonResult("操作失败", false);
        }
    }
}
